home *** CD-ROM | disk | FTP | other *** search
/ comtecelectrical.ca / www.comtecelectrical.ca.tar / www.comtecelectrical.ca / infobots / Backup / MSOCache / All Users / 90000409-6000-11D3-8CFE-0150048383C9 / Q2561411.CAB / POWERPNT.EXE / RCDATA / 5946 < prev    next >
Text File  |  2003-07-30  |  4KB  |  146 lines

  1.  
  2. /*********************************************
  3.  Context menu implementation
  4.  
  5.  _CM() is the function that's hooked up to
  6.  the oncontextmenu event. Once we're asked to
  7.  show the menu, we first build it by creating
  8.  DIVs on-the-fly. Then we position it 
  9.  within the screen area so it doesn't get
  10.  clipped.
  11.  
  12.  Creating the DIVs using createElement() means
  13.  we don't have to write out any extra HTML
  14.  into the slide HTML files.
  15. **********************************************/
  16. var sNext="^0",sPrev="^1",sEnd="^2",sFont="^3",sArrow="^4",sFreeform="^5",sRect="^6",sOval="^7"
  17.  
  18. function ShowMenu()
  19. {
  20.     BuildMenu();
  21.     var doc=PPTSld.document.body,x=PPTSld.event.clientX+doc.scrollLeft,y=PPTSld.event.clientY+doc.scrollTop
  22.     m = PPTSld.document.all.item("ctxtmenu")
  23.     m.style.pixelLeft=x
  24.     if( (x+m.scrollWidth > doc.clientWidth)&&(x-m.scrollWidth > 0) )
  25.         m.style.pixelLeft=x-m.scrollWidth
  26.  
  27.     m.style.pixelTop=y
  28.     if( (y+m.scrollHeight > doc.clientHeight)&&(y-m.scrollHeight > 0) )
  29.         m.style.pixelTop=y-m.scrollHeight
  30.  
  31.     m.style.display=""
  32. }
  33.  
  34. function _CM()
  35. {
  36.     if( !parent.IsFullScrMode() ) return;
  37.     if(!PPTSld.event.ctrlKey) {
  38.         ShowMenu()
  39.         return false
  40.     } else
  41.         HideMenu()
  42. }
  43.  
  44. function BuildMenu()
  45. {
  46.     if( PPTSld.document.all.item("ctxtmenu") ) return
  47.  
  48.     var mObj=CreateItem( PPTSld.document.body )
  49.     mObj.id="ctxtmenu"
  50.     mObj.style.visibility="hidden"
  51.     var s=mObj.style
  52.     s.position="absolute"
  53.     s.cursor="default"
  54.     s.width="120px"
  55.     SetCMBorder(mObj,"menu","black")
  56.  
  57.     var iObj=CreateItem( mObj )
  58.     SetCMBorder( iObj, "threedhighlight","threedshadow" )
  59.     iObj.style.padding=2
  60.     CreateMenuItem( iObj,sNext,M_GoNextSld,M_True )
  61.     CreateMenuItem( iObj,sPrev,M_GoPrevSld,M_HasPrevSld )
  62.     
  63.     CreateSeparator( iObj )
  64.     CreateMenuItem( iObj,sEnd,M_End,M_True )
  65.     mObj.style.visibility="visible"
  66. }
  67.  
  68. function Cancel() { window.event.cancelBubble=true; window.event.returnValue=false }
  69.  
  70. function Highlight() { ChangeClr("activecaption","threedhighlight") }
  71.  
  72. function Deselect() { ChangeClr("threedface","menutext") }
  73.  
  74. function Perform()
  75. {
  76.     e=PPTSld.event.srcElement
  77.     if( e.type=="menuitem" && e.IsActive() )
  78.         e.Action()
  79.     else
  80.         PPTSld.event.cancelBubble=true
  81. }
  82. function ChangeClr( bg,clr )
  83. {
  84.     e=PPTSld.event.srcElement
  85.     if( e.type=="menuitem" && e.IsActive() ) {
  86.         e.style.backgroundColor=bg
  87.         e.style.color=clr
  88.     }
  89. }
  90.  
  91. function M_HasPrevSld() { return( parent.HasPrevSld() ) }
  92.  
  93. function M_GoNextSld() { if( gIsEndShow ) M_End(); else GoToNextSld() }
  94.  
  95. function M_GoPrevSld() { if( gIsEndShow ) { gIsEndShow=0; history.back(); PPTSld.event.cancelBubble=true; } else GoToPrevSld() }
  96.  
  97. function M_True() { return true }
  98.  
  99. function M_End() { window.close( self ) }
  100.  
  101. function CreateMenuItem( node,text,action,eval )
  102. {
  103.     var e=CreateItem( node )
  104.     e.type="menuitem"
  105.     e.Action=action
  106.     e.IsActive=eval
  107.     e.innerHTML=text
  108.  
  109.     if( !e.IsActive() )
  110.         e.style.color="threedshadow"
  111.  
  112.     e.onclick=Perform
  113.     e.onmouseover=Highlight
  114.     e.onmouseout=Deselect
  115.     s=e.style;
  116.     s.fontFamily=sFont
  117.     s.fontSize="^8"
  118.     s.paddingLeft=2
  119. }
  120.  
  121. function CreateSeparator( node )
  122. {
  123.     var sObj=CreateItem( node )
  124.     SetCMBorder(sObj,"menu","menu")
  125.     var s=sObj.style
  126.     s.borderTopColor="threedshadow"
  127.     s.borderBottomColor="threedhighlight"
  128.     s.height=1
  129.     s.fontSize="0px"
  130. }
  131.  
  132. function CreateItem( node )
  133. {
  134.     var elem=PPTSld.document.createElement("DIV")
  135.     node.insertBefore( elem )
  136.     return elem
  137. }
  138.  
  139. function SetCMBorder( o,ltClr,rbClr )
  140. {
  141.     var s=o.style
  142.     s.backgroundColor="menu"
  143.     s.borderStyle="solid"
  144.     s.borderWidth=1
  145.     s.borderColor=ltClr+" "+rbClr+" "+rbClr+" "+ltClr
  146. }